package com.daishuaiqing.blog.serviceImpl;

import com.daishuaiqing.blog.dao.ArticleTypeDao;
import com.daishuaiqing.blog.entity.ArticleType;
import com.daishuaiqing.blog.model.MyResult;
import com.daishuaiqing.blog.model.SuccessResult;
import com.daishuaiqing.blog.service.ArticleTypeService;
import com.daishuaiqing.blog.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ArticleTypeServiceImpl implements ArticleTypeService {
    @Autowired
    ArticleTypeDao articleTypeDao;
    @Override
    public MyResult getList() {
        return new SuccessResult(articleTypeDao.findAll());
    }

    @Override
    public MyResult add(ArticleType articleType) {
        articleType.setCreateTime(DateUtil.getUnixMillis());
        articleType.setDeleteFlag(false);
        return new SuccessResult(articleTypeDao.save(articleType));
    }
}
